package com.hspedu.newData.dmsxl.树;

import com.hspedu.newData.dmsxl.ds.TreeNode;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-28 
 * @Version: 1.0
 */

public class LC1379找出克隆二叉树中的相同节点 {

    public final TreeNode getTargetCopy(final TreeNode original, final TreeNode cloned, final TreeNode target) {

        if (target == null) {
            return null;
        }
        if (cloned == target){
            return cloned;
        }

        TreeNode targetCopy = getTargetCopy(original.left, cloned.left, target);
        if (targetCopy!=null){
            return targetCopy;
        }
        return getTargetCopy(original.right,cloned.right,target);

    }

}
